package com.tpay.client.gin;

import com.google.inject.Singleton;
import com.gwtplatform.dispatch.shared.SecurityCookie;
import com.gwtplatform.mvp.client.gin.AbstractPresenterModule;
import com.gwtplatform.mvp.client.gin.DefaultModule;
import com.tpay.client.NameTokens;
import com.tpay.client.place.DefaultPlace;
import com.tpay.client.place.PayPlaceManager;
import com.tpay.client.presenter.AdminGatekeeper;
import com.tpay.client.presenter.ErrorPagePresenter;
import com.tpay.client.presenter.LoggedInGatekeeper;
import com.tpay.client.presenter.MainPagePresenter;
import com.tpay.client.view.ErrorPageView;
import com.tpay.client.view.MainPageView;
import com.tpay.shared.SharedTokens;

public class SharedGinModule extends AbstractPresenterModule {

	@Override
	protected void configure() {
		this.install(new DefaultModule(PayPlaceManager.class));
		
		this.bind(LoggedInGatekeeper.class).in(Singleton.class);
		this.bind(AdminGatekeeper.class).in(Singleton.class);
		
		this.bindConstant().annotatedWith(SecurityCookie.class).to(SharedTokens.securityCookieName);
		this.bindConstant().annotatedWith(DefaultPlace.class).to(NameTokens.loginPage);
		
		bindPresenter(ErrorPagePresenter.class, ErrorPagePresenter.MyView.class, ErrorPageView.class, ErrorPagePresenter.MyProxy.class);
		bindPresenter(MainPagePresenter.class, MainPagePresenter.MyView.class, MainPageView.class, MainPagePresenter.MyProxy.class);
	}

}
